<?php get_header(); ?>
        
        <!-- MIDDLE -->
        <section class="middle row">
		
			<!-- TAGLINE -->
			<?php if ( get_option( 'tagline_text' ) != "" ) { echo '<div class="tagline span12"><h3>' . stripcslashes( get_option( 'tagline_text' ) ) . '</h3></div>'; } ?>
			<!-- TAGLINE -->
        
			<?php
			
				if ( get_option( 'slider_type' ) == "Big" )
				{
					$args = array( 'post_type' => 'slides', 'posts_per_page' => -1 );
					$loop = new WP_Query( $args );
				
					if ( $loop->have_posts() ) :
					
						?>
						
							<!-- big SLIDER -->
							<div class="flex-container main-slider main-slider-narrow span12">
							
								<?php
								
									if ( get_option( 'enable_video_in_slider_area' ) )
									{
										echo '<div class="media-box video-container">';
										
											echo stripcslashes( get_option( 'video_code_in_slider_area' ) );
											
										echo '</div>';
									}
									else
									{
									?>
									
										<div class="flexslider">
									  
											<ul class="slides">
											
												<?php
													
													while ( $loop->have_posts() ) : $loop->the_post();
													
														if ( ! get_option( $post->ID . 'for_blog_page_slider' ) )
														{
															echo '<li>';
															
																$slide_img_alt_text = get_option( $post->ID . 'slide_img_alt_text' );
														
																if ( has_post_thumbnail() )
																{
																	$image_link = get_post_meta( $post->ID, 'image_link', true );
																	$image_new_window = get_post_meta( $post->ID, 'image_new_window', true );
																	
																	if ( $image_link )
																	{
																		?>
																		
																			<a <?php if ( $image_new_window ) { echo 'target="_blank"'; } ?> href="<?php echo $image_link; ?>">
																				
																				<?php the_post_thumbnail( 'full', array( 'alt' => $slide_img_alt_text, 'title' => "" ) ); ?>
																				
																			</a>
																		
																		<?php
																	}
																	else
																	{
																		the_post_thumbnail( 'full', array( 'alt' => $slide_img_alt_text, 'title' => "" ) );
																	}
																}
																else
																{
																	?>
																	
																		<img src="<?php echo get_template_directory_uri(); ?>/img/slider/slider-placeholder.png" alt="<?php echo $slide_img_alt_text; ?>" />
																	
																	<?php
																}
																
																$image_caption = get_post_meta( $post->ID, 'image_caption', true );
																
																if ( $image_caption )
																{
																	echo '<h2 class="flex-caption">';
																		echo $image_caption;
																	echo '</h2>';
																}
															
															echo '</li>';
														}
														// end for_blog_page_slider
														
													endwhile;
												
												?>
												
											</ul>
										
										</div>
								
									<?php
									}
								
								?>
							  
							</div>
							<!-- end big SLIDER -->
							
						<?php
				
					endif;
					
					wp_reset_query();
				}
				else
				{
					$args = array( 'post_type' => 'slides', 'posts_per_page' => -1 );
					$loop = new WP_Query( $args );
					
					if ( $loop->have_posts() ) :
				
					?>
					
						<!-- small SLIDER -->
						<div class="flex-container main-slider main-slider-narrow span8">
						
							<?php
							
								if ( get_option( 'enable_video_in_slider_area' ) )
								{
									echo '<div class="media-box video-container">';
									
										echo stripcslashes( get_option( 'video_code_in_slider_area' ) );
										
									echo '</div>';
								}
								else
								{
								?>
								
									<div class="flexslider">
								  
										<ul class="slides">
										
											<?php
											
												while ( $loop->have_posts() ) : $loop->the_post();
												
													if ( ! get_option( $post->ID . 'for_blog_page_slider' ) )
													{
														echo '<li>';
														
															$slide_img_alt_text = get_option( $post->ID . 'slide_img_alt_text' );
													
															if ( has_post_thumbnail() )
															{
																$image_link = get_post_meta( $post->ID, 'image_link', true );
																$image_new_window = get_post_meta( $post->ID, 'image_new_window', true );
																
																if ( $image_link )
																{
																	?>
																	
																		<a <?php if ($image_new_window) echo 'target="_blank"' ?> href="<?php echo $image_link; ?>">
																		
																			<?php the_post_thumbnail( 'full', array( 'alt' => $slide_img_alt_text, 'title'	=> "" ) ); ?>
																		
																		</a>
																		
																	<?php
																}
																else
																{
																	the_post_thumbnail( 'full', array( 'alt' => $slide_img_alt_text, 'title' => "" ) );
																}
															}
															else
															{
																?>
																
																	<img src="<?php echo get_template_directory_uri(); ?>/img/slider/slider-placeholder.png" alt="<?php echo $slide_img_alt_text; ?>">
																	
																<?php
															}
															
															$image_caption = get_post_meta( $post->ID, 'image_caption', true );
															
															if ( $image_caption )
															{
																echo '<h2 class="flex-caption">';
																	echo $image_caption;
																echo '</h2>';
															}
														
														echo '</li>';
													}
													// end for_blog_page_slider
													
												endwhile;
										
										?>
											
										</ul>
									
									</div>
									
								<?php
								}
							
							?>
						  
						</div>
						<!-- end small SLIDER -->
						
					<?php
						
						endif;
					
						wp_reset_query();
						
					?>
						
						<!-- ASIDE -->
						<aside class="aside span4">
						
						<?php
						
							if ( get_option( 'hide_cta_info' ) )
							{
								if ( ! function_exists( 'dynamic_sidebar' ) || ! dynamic_sidebar( "cta_sidebar" ) ) :
								endif;
							}
							else
							{
								if ( get_option( 'cta_title' ) != "" ) { echo '<h2>' . stripcslashes( get_option( 'cta_title' ) ) . '</h2>'; }
								
								if ( get_option( 'cta_text' ) != "" ) { echo '<p>' . stripcslashes( get_option( 'cta_text' ) ) . '</p>'; }

								if ( get_option( 'cta_button_text' ) != "" )
								{
									$cta_button_color = get_option( 'cta_button_color' );
									
									if ( $cta_button_color == "White" ) { $cta_button_color_out = "btn-default"; }
									elseif ( $cta_button_color == "Blue" ) { $cta_button_color_out = "btn-primary"; }
									elseif ( $cta_button_color == "Sky Blue" ) { $cta_button_color_out = "btn-info"; }
									elseif ( $cta_button_color == "Green" ) { $cta_button_color_out = "btn-success"; }
									elseif ( $cta_button_color == "Yellow" ) { $cta_button_color_out = "btn-warning"; }
									elseif ( $cta_button_color == "Red" ) { $cta_button_color_out = "btn-danger"; }
									else { $cta_button_color_out = ""; }
									
									if ( get_option( 'cta_button_url' ) != "" ) { $cta_button_url_out = 'href="' . get_option( 'cta_button_url' ) . '"'; }
								
									echo '<p><a class="btn btn-large ' . $cta_button_color_out . '" ' . $cta_button_url_out . '>' . stripcslashes( get_option( 'cta_button_text' ) ) . '</a></p>';
								}
							}
							
						?>
						
						</aside>
						<!-- end ASIDE -->
						
					<?php
				
				}
			?>

			<!-- WIDGETS -->
			<?php
			
				if ( !function_exists( 'dynamic_sidebar' ) || !dynamic_sidebar( "homepage_with_portfolio_sidebar" ) ) :
				endif;
			
			?>
			<!-- end WIDGETS -->
			
            <!-- PORTFOLIO WRAP -->
            <div class="portfolio-wrap span12">

                <!-- PAGE HEADER -->
                <div class="page-header">
				
					<h1 style="float: left; min-width: 50%;">
					
						<b><?php single_post_title(); ?></b>
						
						<small><?php echo stripcslashes( get_option( get_the_ID() . 'page_subtitle' ) ); ?></small>
						
					</h1>
					
					<?php
					
						if ( ! get_option( 'disable_portfolio_search' ) )
						{
							?>
								<form style="float: right; margin-bottom: 0px; padding-top: 4px;" method="get" action="<?php echo home_url( '/' ); ?>">
								
									<div class="input-append" style="margin-bottom: 0px;">
									
										<input type="text" id="appendedPrependedInput" name="s" size="16" class="span3" style="padding: 6px !important; margin-bottom: 0px; max-width: 220px;" placeholder="<?php echo __( 'Enter keyword...', 'responsy' ); ?>" value="<?php the_search_query(); ?>">
										
										<input type="submit" id="searchsubmit" class="send" style="display: none;" value="Go">
										
									  </div>
									  
								</form>
							<?php
						}
					
					?>
					
					<div style="clear: both;"></div>
					
				</div>
                <!-- end PAGE HEADER -->
               
                <!--FILTERS-->
				<?php
				
					$pf_terms = get_categories( 'type=portfolio&taxonomy=department' );
					
				?>
				
                <ul id="filters">
				
					<li class="current"><a href="#" data-filter="*"><?php echo __( 'all', 'responsy' ); ?></a></li>
					
					<?php
					
						foreach( $pf_terms as $pf_term ) :
						
					?>
					
						<li>
							<a href="#" data-filter=".<?php echo $pf_term->slug; ?>"><?php echo $pf_term->name; ?></a>
						</li>
						
					<?php
					
						endforeach;
						
					?>
					
                </ul>
                <!-- end FILTERS -->

                <!-- PORTFOLIO -->
                <div id="portfolio" class="portfolio-items">
				
					<?php
					
						$args_portfolio = array( 'post_type' => 'portfolio', 'posts_per_page' => -1 );
						$loop_portfolio = new WP_Query( $args_portfolio );
						
						if ( $loop_portfolio->have_posts() ) :
						
							while ( $loop_portfolio->have_posts() ) : $loop_portfolio->the_post();
								
								$terms = get_the_terms( $post->ID, 'department' );
								$on_draught = '';
								
								if ( $terms && ! is_wp_error( $terms ) ) :
									
									$draught_links = array();

									foreach ( $terms as $term )
									{
										$draught_links[] = $term->slug;
									}
							
									$on_draught = join( " ", $draught_links );
									
								endif;
							
							?>
							
							<div class="item <?php echo $on_draught; ?>">
							
								<div class="media-box">
								
									<?php
									
										if ( has_post_thumbnail() )
										{
											if ( get_option( 'no_crop_portfolio_page' ) )
											{
												the_post_thumbnail( 'full', array( 'alt' => get_the_title(), 'title' => "" ) );
											}
											else
											{
												the_post_thumbnail( 'portfolio_page_img', array( 'alt' => get_the_title(), 'title'	=> "" ) );
											}
										}
										else
										{
											?>
												<img src="<?php echo get_template_directory_uri(); ?>/img/blog/blog-placeholder.png" alt="<?php echo get_the_title(); ?>">
											<?php
										}
									?>
									
									<div class="mask">
									
										<h3 class="title"><?php if ( get_option( 'see_project_details_text' ) != "" ) { echo stripcslashes( get_option( 'see_project_details_text' ) ); } else { echo "SEE PROJECT DETAILS"; } ?></h3>
										
										<?php
											
											$enable_pretty_photo = '';
											$pretty_photo_title = '';
										
											if ( get_option( $post->ID . 'open_portfolio_item_in_lightbox' ) )
											{
												if ( has_post_thumbnail() )
												{
													$portfolio_item = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' );
													
													$portfolio_item_url = $portfolio_item[0];
												}
												else
												{
													$portfolio_item_url = get_template_directory_uri() . '/img/blog/blog-placeholder.png';
												}
												
												$enable_pretty_photo = 'rel="prettyPhoto[portfolio]"';
												$pretty_photo_title = 'title="' . get_the_title() . '"';
											}
											else
											{
												$portfolio_item_url = get_permalink();
											}
											
										?>
										
										<a class="ico full" href="<?php echo $portfolio_item_url; ?>" <?php echo $enable_pretty_photo . ' ' . $pretty_photo_title; ?>></a>
										
									</div>
									
								</div>
								
								<h3 class="project-title"><?php the_title(); ?></h3>
								
								<p class="category"><?php echo get_post_meta( $post->ID, 'short_description', true ); ?></p>
								
							</div>
							
							<?php
							
							endwhile;
							
						endif;
						
						wp_reset_query();
					
					?>
				
                </div>
                <!-- end PORTFOLIO -->
				
            </div>
            <!-- end PORTFOLIO WRAP -->

        </section>
        <!-- end MIDDLE -->
		
    </div>
    <!-- end CONTAINER -->
	
<?php

	get_footer();
	
?>